home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-9.10-netbook-remix-PL.iso / casper / filesystem.squashfs / etc / dhcp3 / dhclient-exit-hooks.d / rfc3442-classless-routes < prev    next >
Text File  |  2009-10-08  |  2KB  |  40 lines

  1. RUN="yes"
  2.  
  3.  
  4. if [ "$RUN" = "yes" ]; then
  5.         if [ "$new_rfc3442_classless_static_routes" != "" ]; then
  6.                 if [ "$reason" = "BOUND" ] || [ "$reason" = "REBOOT" ]; then
  7.                         rfc_routes=($new_rfc3442_classless_static_routes)
  8.  
  9.                         for(( i=0; i < ${#rfc_routes[@]}; )); do
  10.                                 net_length=${rfc_routes[$i]}
  11.  
  12.                                 ((i++))
  13.  
  14.                                 net_address=(0 0 0 0)
  15.                                 for(( j=0; j < $[$net_length / 8 + \
  16.                                     ($net_length % 8 ? 1 : 0)]; j++, i++)); do
  17.  
  18.                                         net_address[$j]=${rfc_routes[$i]}
  19.                                 done
  20.  
  21.                                 gateway=(0 0 0 0)
  22.                                 for (( j=0; j < 4; j++, i++ )); do
  23.                                         gateway[$j]=${rfc_routes[$i]}
  24.                                 done
  25.  
  26.                                 old_IFS="$IFS"
  27.                                 IFS='.'
  28.  
  29.                                 if [ "$net_length" == "32" ]; then
  30.                                         /sbin/route add -host "${net_address[*]}" gw "${gateway[*]}"
  31.                                 else
  32.                                         /sbin/route add -net "${net_address[*]}/$net_length" gw "${gateway[*]}"
  33.                                 fi
  34.                                 IFS="$old_IFS"
  35.  
  36.                         done
  37.                 fi
  38.         fi
  39. fi
  40.